<template>
  <div>
    Dashboard
  </div>
</template>

<script>
import {
  mapMutations
} from 'vuex'
import { Loading} from 'element-ui';
export default {
  data(){
    return {
      myloading:'',
      text:60,
      Loading
    }
  },
  methods:{
      ...mapMutations([
        'changeAvatar'
      ])
    },
  created() {
    console.log(this.Loading)
   
    this.$ajax.getInit()
    .then(res=>{
      // console.log(res)
      this.changeAvatar({
        avatar:'http://127.0.0.1:3005/'+res.data[0].avatar
      })
       this.myloading = this.Loading.service({
      background:'rgba(0,0,0,0.3)',
        text:'倒计时：'+20
      });
      var n=20
      var timer=setInterval(() => {
        n--
        console.log(this.text)
        document.querySelector(".el-loading-text").innerHTML='倒计时：'+n
        if(n===0)
        {
          this.myloading.close()
          clearInterval(timer)
        }
      }, 1000);
    })
  },
}
</script>

<style>

</style>
